package com.mall.business.controller;


import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.mall.common.annotation.Log;
import com.mall.common.core.controller.BaseController;
import com.mall.common.core.domain.AjaxResult;
import com.mall.common.enums.BusinessType;
import com.mall.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mall.business.domain.TYqUser;
import com.mall.business.service.ITYqUserService;
import com.mall.common.core.page.TableDataInfo;

/**
 * 邀请人Controller
 *
 * @author ruoyi
 * @date 2025-05-28
 */
@RestController
@RequestMapping("/business/yquser" )
public class TYqUserController extends BaseController {
    @Autowired
    private ITYqUserService tYqUserService;

/**
 * 查询邀请人列表
 */
//@RequiresPermissions("business:yquser:list")
@GetMapping("/list" )
    public TableDataInfo list(TYqUser tYqUser) {
        startPage();
        List<TYqUser> list = tYqUserService.selectTYqUserList(tYqUser);
        return getDataTable(list);
    }

    /**
     * 导出邀请人列表
     */
    //@RequiresPermissions("business:yquser:export")
    @Log(title = "邀请人" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, TYqUser tYqUser) {
        List<TYqUser> list = tYqUserService.selectTYqUserList(tYqUser);
        ExcelUtil<TYqUser> util = new ExcelUtil<TYqUser>(TYqUser. class);
        util.exportExcel(response, list, "邀请人数据" );
    }

    /**
     * 获取邀请人详细信息
     */
    //@RequiresPermissions("business:yquser:query")
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) String id) {
        return AjaxResult.success(tYqUserService.getById(id));
    }

    /**
     * 新增邀请人
     */
    //@RequiresPermissions("business:yquser:add")
    @Log(title = "邀请人" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TYqUser tYqUser) {
        return toAjax(tYqUserService.save(tYqUser));
    }

    /**
     * 修改邀请人
     */
    //@RequiresPermissions("business:yquser:edit")
    @Log(title = "邀请人" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TYqUser tYqUser) {
        return toAjax(tYqUserService.updateById(tYqUser));
    }

    /**
     * 删除邀请人
     */
    //@RequiresPermissions("business:yquser:remove")
    @Log(title = "邀请人" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tYqUserService.removeByIds(Arrays.asList(ids)));
    }
}
